(function( $ ) {
	
	var GetDefaultBaseUrl = function() {
		var protocol = document.location.protocol + "//";
		var hostname = document.location.hostname;
		var port = document.location.port !== '' ? ":" + document.location.port : "";

		return protocol + hostname + port;
	};

	// returns jqXhr object.
	$.wPost = function( endpoint, data ) {
		return $.ajax({
			url: GetDefaultBaseUrl() + endpoint,
			dataType: "json",
			type: "POST",
			processData: false,
			contentType: "application/json",
			data: data
		});
	};

	$.wGet = function( endpoint, data ) {
		return $.ajax({
			url: GetDefaultBaseUrl() + endpoint,
			dataType: "json",
			type: "GET",
			processData: false,
			contentType: "application/json"
		});
	};

	$.wPut = function( endpoint, data ) {
		return $.ajax({
			url: GetDefaultBaseUrl()+ route,
			dataType: "json",
			type: "POST",
			processData: false,
			contentType: "application/json",
			data: data,
			beforeSend: function( xhr )
			{
				xhr.setRequestHeader("X-Http-Method-Override", "PUT");
			}
		});
	};

	$.wDelete = function( endpoint, data ) {
		return $.ajax({
			url: GetDefaultBaseUrl() + endpoint,
			dataType: "json",
			type: "POST",
			processData: false,
			contentType: "application/json",
			beforeSend: function(xhr)
			{
				xhr.setRequestHeader("X-Http-Method-Override", "DELETE");
			}
		});
	};

})( jQuery );